package com.ysstech.finance.enums;

import java.util.Arrays;
import java.util.Objects;

import com.ysstech.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum FinanceEnum implements BaseEnum<String> {
    ASSETSTYPE_CODE("ASSETSTYPE_CODE", "科目资产类型（资产类，负债类，共同类，权益类，损益类）"),
    ADJUST_CODE("ADJUST_CODE", "核算项"),
    CURRENCY("CURRENCY", "币种"),
    VOUCHER_SOURCE("VOUCHER_SOURCE", "凭证来源，股票凭证，债券品种，计息品种等"),
    VOUCHER_TYPE("VOUCHER_TYPE", "凭证类型，上海普通股票买入，上海普通股票卖出，深圳普通股票买入等");
    private final String code;
    private final String desc;

    public static FinanceEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        FinanceEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
